﻿using System;
using System.Collections.Generic;
using System.Text;

namespace UpYun.Storage.Model
{
    /// <summary>
    /// 文件
    /// </summary>
    public class FilesModel
    {
        /// <summary>
        /// 文件名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 文件类型
        /// </summary>
        public string Type { get; set; }

        /// <summary>
        /// 文件类型
        /// </summary>
        public FileTypeEnum FileType
        {
            get
            {
                return this.Type?.Equals("folder", StringComparison.OrdinalIgnoreCase) == true ? FileTypeEnum.Folder : FileTypeEnum.File;
            }
        }

        /// <summary>
        /// 大小
        /// </summary>
        public long Length { get; set; }

        /// <summary>
        /// 路径
        /// </summary>
        public string Path { get; set; }

        /// <summary>
        /// 最后修改日期
        /// </summary>
        public long last_modified { get; set; }

        /// <summary>
        /// 最后修改日期
        /// </summary>
        public DateTime LastModified
        {
            get
            {
                DateTime ticks = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                return new DateTime(ticks.Ticks + this.last_modified * 10000000);
            }
        }

        /// <summary>
        /// 文件MD5值
        /// </summary>
        public string ContentMD5 { get; set; }
    }
}
